package com.atguigu.hellomp;

import com.atguigu.hellomp.entity.User;
import com.atguigu.hellomp.mapper.UserMapper;
import com.atguigu.hellomp.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @BelongsProject: lease
 * @BelongsPackage: com.atguigu.hellomp
 * @Author: jiangyi
 * @CreateTime: 2025-08-13  18:10
 * @Description: TODO
 * @Version: 1.0
 */
@SpringBootTest
public class test01 {

    @Autowired
    UserMapper userMapper;

    @Autowired
    UserService userService;

    @Test
    public void test01() {

        User user = userMapper.selectById(1);
        System.out.println(user);
    }

    @Test
    public void test02() {
        User user = userService.getById(1L);

    }

    @Test
    public void testSaveBatch() {
        User user1 = new User();
        user1.setName("扫地哥");
        user1.setAge(3);
        user1.setEmail("saodi@email.com");
        userMapper.insert(user1);
    }


    @Test
    public void testUpdateBatch() {
        User user = new User();
        user.setId(1L);
        user.setName("Coco");
        user.setAge(49);
        user.setEmail("coco@email.com");
        // 自动拼接动态 SQL
        userMapper.updateById(user);
    }


}
